var utils = require("../../utils/utils");
var ocrGml = require("../../utils/ocrGml");
var ACTION = require("../../base/action");
var actionTreasure = new ACTION("开宝箱");
actionTreasure.exec = function () {
  var contents = ["开宝箱得金币"];
  var ocrItem = ocrGml.captureExistOne(contents, true);
  if (ocrItem) {
    utils.clickOcrItem(ocrItem);
    sleep(utils.getRandom(2.5, 3, 1000));
    var contents = ["开心收下", "立即收下"];
    var ocrItem = ocrGml.captureExistOne(contents, true);
    if (ocrItem) {
      utils.clickOcrItem(ocrItem);
      sleep(utils.getRandom(2, 3, 1000));
      return;
    }
    return;
  }
};

module.exports = actionTreasure;
